package models

import (
	_ "github.com/jinzhu/gorm/dialects/mysql"
)

//用户
type User struct {
	Id       int    `gorm:"primary_key" json:"id" form:"id"`
	Name     string `json:"name" form:"name"`             //名称
	Address  string `json:"address" form:"address"`       //住址
	Phone    string `json:"phone" form:"phone"`           //联系方式
	Type     int    `json:"type_admin" form:"type_admin"` //用户权限:0.一般用户,1.商户.2.管理员
	Image    string `json:"image" form:"image"`           //头像地址
	Username string `json:"username" form:"username"`     //登录用户名
	Password string `json:"password" form:"password"`     //登录密码
}

type Shoppingcar struct {
	Id          int `gorm:"primary_key" json:"id" form:"id"`
	CommodityId int `json:"commodity_id" form:"commodity_id"` //商品id
	UserId      int `json:"user_id" form:"user_id"`           //所有者id
	Number      int `json:"number" form:"number"`             //数量
}

type UserCollection struct {
	Id               int `gorm:"primary_key" json:"id" form:"id"`
	UserId           int `json:"user_id" form:"user_id"`                       //所有者id
	CollectionUserId int `json:"collection_user_id" form:"collection_user_id"` //关注的用户id
}

func (User) TableName() string {
	return "user"
}

func (Shoppingcar) TableName() string {
	return "shoppingcar"
}

func (UserCollection) TableName() string {
	return "user_collection"
}

func (p *User) AddUser() (id int64, err error) {

	return
}

func (p *User) GetUser() (persons []User, err error) {

	return
}


